package Service;

import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import wendy.watson.mapping.User;

import com.alibaba.fastjson.JSON;

import Dao.ScheduleDao;

@Service(value = "scheduleService")
public class ScheduleServiceImp implements ScheduleService {
    
	@Resource(name = "scheduleDao")
	private ScheduleDao scheduleDao;
	public ScheduleDao getScheduleDao() {
		return scheduleDao;
	}
	public void setScheduleDao(ScheduleDao scheduleDao) {
		this.scheduleDao = scheduleDao;
	}
	public ScheduleServiceImp() {
		// TODO Auto-generated constructor stub
	}
	@Override
	public String createschedule() {
		// TODO Auto-generated method stub
	scheduleDao.createschedule();
		
		
		
		
		
		return null;
	}
	@Override
	public String show(String round, String teamleft, String teamright,
			String time, String page, String rows) {
		// TODO Auto-generated method stub
		
		int PageNow = Integer.parseInt(page);
		int PageSize = Integer.parseInt(rows);
		//System.out.println(round+"");
		//int rounds = Integer.parseInt(round+"");
		int from = PageSize*(PageNow-1);
		int to = PageSize;
		
		System.out.println("round "+round);
		System.out.println("teamleft "+teamleft);
		System.out.println("teamright "+teamright);
		System.out.println("time "+time);
		System.out.println("page "+page);
		System.out.println("rows "+rows);
		System.out.println("from "+page);
		System.out.println("to "+rows);
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("round", round);
		map.put("teamleft", teamleft);
		map.put("teamright", teamright);
		map.put("time", time);
		map.put("from", from);
		map.put("to", to);
		
		String listUser = scheduleDao.show(map);
		System.out.println("Service读取数据成功？："+listUser);
		return listUser;

	}
	@Override
	public String list(String page, String rows) {
		// TODO Auto-generated method stub
		
		int PageNow = Integer.parseInt(page);
		int PageSize = Integer.parseInt(rows);
		
	
		int from = PageSize*(PageNow-1);
		int to = PageSize;
		
		
		System.out.println("page "+page);
		System.out.println("rows "+rows);
		System.out.println("from "+page);
		System.out.println("to "+rows);
		HashMap<String, Object> map = new HashMap<String, Object>();
	
		map.put("from", from);
		map.put("to", to);
		
		String listUser = scheduleDao.show(map);
		System.out.println("Service读取数据成功？："+listUser);
		return listUser;

	}
	
	@Override
	public String union(String team, String page, String rows) {
		// TODO Auto-generated method stub
		int PageNow = Integer.parseInt(page);
		int PageSize = Integer.parseInt(rows);
		
	
		int from = PageSize*(PageNow-1);
		int to = PageSize;
		
		System.out.println("team "+team);
		System.out.println("page "+page);
		System.out.println("rows "+rows);
		System.out.println("from "+page);
		System.out.println("to "+rows);
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("team", team);
		map.put("from", from);
		map.put("to", to);
		
		String listUser = scheduleDao.union(map);
		System.out.println("Service读取数据成功？："+listUser);
		return listUser;
	}
	@Override
	public String euro() {
		// TODO Auto-generated method stub
		String listUser = scheduleDao.euro();
		System.out.println("Service读取数据成功？："+listUser);
		return listUser;
	}
	@Override
	public String vsbyone(String teamleft, String teamright) {
		// TODO Auto-generated method stub
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		map.put("teamleft", teamleft);
		map.put("teamright", teamright);
		
		
		String listUser = scheduleDao.vsbyone(map);
		System.out.println("Service读取数据成功？："+listUser);
		return listUser;
	}
	@Override
	public String round(String round) {
		// TODO Auto-generated method stub
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("round", round);
		String listUser = scheduleDao.round(map);
		System.out.println("Service读取数据成功？："+listUser);
		return listUser;
	}
	@Override
	public String ground() {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		String listUser = scheduleDao.ground();
		System.out.println("Service读取数据成功？："+listUser);
		return listUser;
	}

}
